import java.applet.Applet;
import java.awt.Button;
import java.awt.TextField;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.Console;
import java.net.URL;
import java.util.Random;

import javax.swing.InputMap;
import javax.swing.KeyStroke;
import javax.swing.UIManager;

import org.openqa.selenium.By;
import org.openqa.selenium.HasInputDevices;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Mouse;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;


public class tootltip {

	public static void main(String[] args) throws Exception {
		int rowcount =0;
		int rowcount1=0;
		WebDriver driver = new RemoteWebDriver(new URL ("http://localhost:4444/wd/hub") , DesiredCapabilities.firefox());
	driver.get("http://31.222.152.184/");
	driver.findElement(By.xpath("//*[@id='gateway-language-list']/li[2]/a")).click();
	Thread.sleep(3000);
	driver.findElement(By.xpath("//*[@id='block-menu-menu-user-menu-top']/div/ul/li[1]/a")).click();
	Thread.sleep(4000);
	driver.findElement(By.xpath("//*[@id='edit-name']")).sendKeys("admin");
	driver.findElement(By.xpath("//*[@id='edit-pass']")).sendKeys("admin");
	driver.findElement(By.xpath("//*[@id='dialog-element']")).click();
	Thread.sleep(5000);
	driver.findElement(By.xpath("//*[@id='secondary_navigation']/div/div/div/ul/li[2]/a")).click();
	Thread.sleep(4000);

	for(int i=1;i<=10;i++){
	try{
		driver.findElement(By.xpath("//*[@id='content']/div/div[1]/div/div/div[2]/table/tbody/tr["+i+"]/td[5]/a"));
	rowcount++;
	
	
	}catch (Exception e) {
		break;
	}
	
    
	}
	System.out.println("row count from the outboubd page is :" + rowcount);
	
	
	Random row =new Random();
	
	int randomRow = row.nextInt(rowcount);
	if(randomRow==0){
		randomRow=randomRow+1;
	}
	System.out.println(randomRow);
     driver.findElement(By.xpath("//*[@id='content']/div/div[1]/div/div/div[2]/table/tbody/tr["+randomRow+"]/td[5]/a")).click();
	driver.switchTo().defaultContent();
	Thread.sleep(4000);
	driver.findElement(By.xpath("//*[@id='dialog-element--3']")).click();
	//Thread.sleep(4000);
	//driver.switchTo().defaultContent();
	//for(int j=1;j<=10;j++){
		//try{
		//	driver.findElement(By.xpath("//*[@id='content']/div/div[1]/div/div/div[2]/table/tbody/tr["+j+"]/td[5]/a"));
		//rowcount1++;
		
		
	//	}catch (Exception e) {
	//		break;
	//	}
		
	//	System.out.println("row count from the outboubd page is :" +rowcount1);
		//}
	
		
	}
	
}
